<?php
//simply security measure to make sure $_REQUEST['host'] is clean
if (isset($_REQUEST['host'])) {
  $tmp=explode(".",$_REQUEST['host']);
  if (empty($tmp[0])) $tmp[0]=$domaindata['host'];
  $_REQUEST['host']=$tmp[0];
}

if(!empty($_REQUEST['webalizerfile'])){
  $webalizerfiletest = explode(".",$_REQUEST['webalizerfile']);
  $webalizerfile = $webalizerfiletest[0].".".$webalizerfiletest[1];
  //get file (whether png or html)
  $page = webalizer_get_file($webalizerfile);
  //if png, output appropriate header
  if(strpos($webalizerfile,'.png')!==false){
    header("Content-type: image/png");
  }
  //change the .png src(s)
  else {
    $page = webalizer_change_png($page, 'src');
  }
} else {
  //get index
  $page = webalizer_sanitise_html(webalizer_get_file('index.html'));
  //change links
  $page = webalizer_change_links($current_url, $page, 'href');
  //change the usage.png src
  $page = webalizer_change_png($page, 'src');
}
//output it
echo $page;
?>
